

int rearrangeCharacters(char *s, char *target)
{
    int times[26] = {0}; // 统计s中字母出现次数
    for (int i = 0; s[i]; i++)
    {
        times[s[i] - 'a']++;
    }
    int ret = 0;
    while (1)
    {   
        // 遍历s直到次数出现负数，即不能再构成target
        for (int i = 0; target[i]; i++)
        {
            times[target[i] - 'a']--;
            if (times[target[i] - 'a'] == -1)
            {
                return ret;
            }
        }
        ret++;
    }
    return ret;
}
